﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ValidatorTest.cs" company="AINg">
//   Alex Nek (R) 2010
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

#region

using JanusLibAing;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace JanusTestProject
{
    /// <summary>
    ///  This is a test class for ValidatorTest and is intended
    ///  to contain all ValidatorTest Unit Tests
    /// </summary>
    [TestClass]
    public class ValidatorTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///  Gets or sets the test context which provides
        ///  information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext
        {
            get { return testContextInstance; }
            set { testContextInstance = value; }
        }

        #region Additional test attributes

        // You can use the following additional attributes as you write your tests:
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext)
        // {
        // }
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup()
        // {
        // }
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize()
        // {
        // }
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup()
        // {
        // }
        #endregion

        /// <summary>
        ///  A test for IsSymbolInRange
        /// </summary>
        [TestMethod]
        public void IsSymbolInRangeTest01()
        {
            char ch = '\0';
            char min = '\0';
            char max = '\0';
            const bool Expected = true;

            bool actual = Validator.IsSymbolInRange(ch, min, max);
            Assert.AreEqual(Expected, actual);
        }

        /// <summary>
        ///  A test for IsSymbolInRange
        /// </summary>
        [TestMethod]
        public void IsSymbolInRangeTest01a()
        {
            char ch = '\0';
            char min = '\0';
            char max = '\x5';
            const bool Expected = true;

            bool actual = Validator.IsSymbolInRange(ch, min, max);
            Assert.AreEqual(Expected, actual);
        }

        /// <summary>
        ///  A test for IsSymbolInRange
        /// </summary>
        [TestMethod]
        public void IsSymbolInRangeTest01b()
        {
            char ch = '\x5';
            char min = '\0';
            char max = '\x5';
            const bool Expected = true;

            bool actual = Validator.IsSymbolInRange(ch, min, max);
            Assert.AreEqual(Expected, actual);
        }

        /// <summary>
        ///  A test for IsSymbolInRange
        /// </summary>
        [TestMethod]
        public void IsSymbolInRangeTest01c()
        {
            char ch = '\x3';
            char min = '\0';
            char max = '\x5';
            const bool Expected = true;

            bool actual = Validator.IsSymbolInRange(ch, min, max);
            Assert.AreEqual(Expected, actual);
        }

        /// <summary>
        ///  A test for IsSymbolInRange
        /// </summary>
        [TestMethod]
        public void IsSymbolInRangeTest02()
        {
            char ch = '\x2';
            char min = '\0';
            char max = '\0';
            const bool Expected = false;

            bool actual = Validator.IsSymbolInRange(ch, min, max);
            Assert.AreEqual(Expected, actual);
        }

        /// <summary>
        ///  A test for IsSymbolInRange
        /// </summary>
        [TestMethod]
        public void IsSymbolInRangeTest02a()
        {
            char ch = '\x0';
            char min = '\x1';
            char max = '\x5';
            const bool Expected = false;

            bool actual = Validator.IsSymbolInRange(ch, min, max);
            Assert.AreEqual(Expected, actual);
        }

        /// <summary>
        ///  A test for IsSymbolInRange
        /// </summary>
        [TestMethod]
        public void IsSymbolInRangeTest02b()
        {
            char ch = '\x6';
            char min = '\x1';
            char max = '\x5';
            const bool Expected = false;

            bool actual = Validator.IsSymbolInRange(ch, min, max);
            Assert.AreEqual(Expected, actual);
        }

        /// <summary>
        ///  A test for IsValidXMLSymbol
        /// </summary>
        [TestMethod]
        public void IsValidXMLSymbolTest()
        {
            char ch = '\0';
            bool expected = false;
            bool actual = Validator.IsValidXMLSymbol(ch);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///  A test for ToSafeString
        /// </summary>
        [TestMethod]
        public void ToSafeStringTest()
        {
            string input = string.Empty;
            string expected = string.Empty;
            string actual = Validator.ToSafeString(input);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ToSafeStringTest01()
        {
            const string Input = "\x9";
            const string Expected = "\x9";

            string safeString = Validator.ToSafeString(Input);
            Assert.AreEqual(Expected, safeString);
        }

        [TestMethod]
        public void ToSafeStringTest01a()
        {
            const string Input = "\x8";
            const string Expected = "*";

            string safeString = Validator.ToSafeString(Input);
            Assert.AreEqual(Expected, safeString);
        }

        [TestMethod]
        public void ToSafeStringTest02()
        {
            const string Input = "abc";
            const string Expected = "abc";

            string safeString = Validator.ToSafeString(Input);
            Assert.AreEqual(Expected, safeString);
        }

        [TestMethod]
        public void ToSafeStringTest03()
        {
            const string Input = "abc\x9";
            const string Expected = "abc\x9";

            string safeString = Validator.ToSafeString(Input);
            Assert.AreEqual(Expected, safeString);
        }

        [TestMethod]
        public void ToSafeStringTest03a()
        {
            const string Input = "abc\x8";
            const string Expected = "abc*";

            string safeString = Validator.ToSafeString(Input);
            Assert.AreEqual(Expected, safeString);
        }

        [TestMethod]
        public void ToSafeStringTest04()
        {
            const string Input = "a\xe bc\x9";
            const string Expected = "a* bc\x9";

            string safeString = Validator.ToSafeString(Input);
            Assert.AreEqual(Expected, safeString);
        }

        [TestMethod]
        public void ToSafeStringTest05()
        {
            const string Input = "\x9\xa\xd";
            const string Expected = "\t\n\r";

            string safeString = Validator.ToSafeString(Input);
            Assert.AreEqual(Expected, safeString);
        }
    }
}